<?php

// 店铺设置

namespace app\client\controller;

use think\Url;
use think\Request;
use think\Session;
use think\Controller;
use app\client\model\Shop as ShopModel;
use app\client\model\ShopHome as ShopHomeModel;

class Shop extends Controller
{

    /**
     * 店铺信息
     * @param Request $request
     * @param ShopModel $shop
     * @param ShopHomeModel $shopHome
     * @return mixed
     */
    public function index(Request $request, ShopModel $shop, ShopHomeModel $shopHome)
    {

        if ($request->instance()->isPost()) {

            $data = $request->instance()->param();

            // 提交数据
            $dispose = $shop->allowField(true)->save($data, ['member_id' => Session::get('shop_id')]);

            if ($dispose) {
                win('操作成功', Url::build('Shop/index'));
            }

            fail('操作失败');

        }

        $data = $shop::get(['member_id' => Session::get('shop_id')]);
        $data['home'] = $shopHome::get(['member_id' => Session::get('shop_id')]);


        return $this->fetch('', [
            "mate_title" => '店铺信息',
            'item'       => $data,

        ]);
    }
}
